package com.example.opengl_fbo;

import android.content.Context;
import android.opengl.GLSurfaceView;
import android.util.AttributeSet;
import android.util.Size;
import android.view.ViewGroup;

public class LammyCameraView extends GLSurfaceView {

    public LammyCameraView(Context context) {
        super(context);
        init();
    }

    public LammyCameraView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init()
    {
        LammyRender lammyRender = new LammyRender(this);
        setEGLContextClientVersion(2);
        setRenderer(lammyRender);

    }

    public void setCameraBestPreviewSize()
    {
        Size previewSize =CameraInterface.getCameraViewSize(this.getContext());
         ViewGroup.LayoutParams  lp =  getLayoutParams();
            lp.width =previewSize.getWidth();
            lp.height =previewSize.getHeight();
            setLayoutParams(lp);
//            LogUtil.e("1 onLayout.......   w = " + getWidth());
//            LogUtil.e("1 onLayout.......   w = " + previewSize.getWidth());
    }

}
